package com.cold.demo.web.util;



public class Assert {

    public static void isNull(Object obj,String msg) throws ParameterException {
        isNull(obj,msg,400);
    }


    public static void isNull(Object obj,String msg,int code) throws ParameterException {
        if (obj == null){
            throwEx(msg, code);
        }
    }

    public static void isTrue(boolean bool,String msg) throws ParameterException {
        isTrue(bool,msg,400);
    }

    public static void isTrue(boolean bool,String msg,int code) throws ParameterException {
        if (bool){
            throwEx(msg, code);
        }
    }


    private static void throwEx(String msg, int code) {
        ParameterException ex = new ParameterException();
        ex.setMsg(msg);
        ex.setCode(code);
        throw ex;
    }
}
